package com.originalpoint.origin_server.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger3.0的配置类
 */
@Configuration //告知spring当前类是一个配置类，当服务器启动的时候会自动加载该类到内存中
@EnableOpenApi //告知当前类是swagger3的配置文件
public class SwaggerConfig {
    @Bean //告知spring当前方法是一个工厂Bean
     public Docket docket(){
         return new Docket(DocumentationType.OAS_30)
                            .apiInfo(apiInfo()).enable(true)
                            .select()
                            .apis(RequestHandlerSelectors.basePackage("com.originalpoint.origin_server"))
                            .paths(PathSelectors.any())
                            .build();
     }

     private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("原点点餐系统接口文档")
                .description("原神启动")
                .contact(new Contact("原神启动","http://www.baidu.com","123456@qq.com"))
                .version("1.0")
                .build();
     }
}

